﻿using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.DtoModel.Schedule.RobotInfo;
using VisionCloud.Domain.Filters;
using VisionCloud.Service.Schedule;

namespace VisionCloud.Api.Controllers.Schedule
{
    /// <summary>
    /// 机器模块控制器
    /// </summary>
    [SystemModule("机器模块控制器")]
    [ApiVersion("1.0")]
    [Route("api/schedule/[Controller]/[Action]")]
    [ApiExplorerSettings(GroupName = "机器模块控制器")]
    public class RobotController : ApiBaseController
    {
        public RobotInfoService RobotInfoService { get; set; }

        /// <summary>
        /// 获取机器人坐标列表
        /// </summary>
        /// <returns></returns>
        [HttpPost, SwaggerOperation(Tags = new[] { "获取机器人坐标列表" })]
        public async Task<ApiResult> GetLocaltionList()
        {
            List<RobotLocaltionDto> data = RobotInfoService.GetLocaltionList();
            return new ApiResult
            {
                Code = AjaxCode.Success,
                Result = data
            };
        }

        /// <summary>
        /// 根据经纬度计算周边机器人，返回3台
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// <remarks>
        /// Sample request:
        /// 
        ///     POST
        ///     {
        ///         "longitude":113.2862481169026,
        ///         "latitude":22.929653086009793
        ///     }
        ///     
        /// </remarks>
        [HttpPost, SwaggerOperation(Tags = new[] { "根据经纬度计算周边机器人，返回3台" })]
        public async Task<ApiResult> RobotSchedule(RobotScheduleRqDto request)
        {
            RobotScheduleDto data = RobotInfoService.Schedule(request);
            return new ApiResult
            {
                Code = AjaxCode.Success,
                Result = data
            };
        }

        /// <summary>
        /// 获取机器人详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet, SwaggerOperation(Tags = new[] { "获取机器人详情" })]
        public async Task<ApiResult> GetRobotDetail(Guid id)
        {
            return new ApiResult
            {
                Code = AjaxCode.Success,
                Result = RobotInfoService.GetRobotDetail(id)
            };
        }
    }
}
